<template>
  <div>
    <div class="bar">
      <ul>
        <li @click="getlist('ALL')">全部</li>
        <li @click="getlist('ZH')">华语</li>
        <li @click="getlist('EA')">欧美</li>
        <li @click="getlist('KR')">韩国</li>
        <li @click="getlist('JP')">日本</li>
      </ul>
      <div>
        <span>推荐</span>
        <span>全部</span>
      </div>
    </div>
    <div class="list">
        <ul>
            <li v-for=" i in list" :key="i.id">
              <div><img v-lazy="i.picUrl" alt=""></div>
              <div class="name">{{i.name}}</div>
              <span class="author" @click.stop="toArtist(i.artist.id)">{{i.artist.name}}</span>
            </li>
          
        </ul>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      list:[]
    }
  },
  methods:{
    getlist(area){
      this.$request({
      url:'/album/new',
      params:{
        area:area
      }
      }).then(success=>{
        this.list=success.data.albums
      })
    },
      toArtist(id){
      this.$router.push({name:'artistInfo',query:{id:id}})
    }
  },
  mounted(){
    this.$request({
      url:'/album/new'
    }).then(success=>{
      this.list=success.data.albums
    })
  }
};
</script>

<style scoped>
li{
  cursor: pointer;
}
.bar {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}
.bar ul {
  display: flex;
}
.bar ul li {
  margin: 0 20px;
  line-height: 30px;
}

.bar div span {
  display: inline-block;
  border: 1px solid #ccc;
  text-align: center;
  margin-left: 10px;
  width: 100px;
  height: 30px;
  line-height: 30px;
  border-radius: 15px;
}
.list{
    margin-top: 20px;
}
.list ul{
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}
.list ul li{
    width: 150px;
    margin-bottom: 20px;
}
.list ul li img{
  height: 150px;
}
.name{
  margin: 10px 0;
}
.author{
  font-size: 14px;
  color: gray;
}
.author:hover{
  color: #444;
}
</style>